package com.supcon.exchangedata.repository.master;

import com.supcon.exchangedata.pojo.entity.oracle.GisPoint;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @program: exchange-data
 * @description:
 * @author: cherubr.Sumin
 * @create: 2021-12-15 14:24
 **/
public interface MasterGisPointRepository extends JpaRepository<GisPoint, Long>,MasterBusRoutesStationRepository {

    public GisPoint findDistinctByObjId(Long objId);

    @Transactional
    public int deleteByObjIdAndYwCategory(Long objId, String ywCategory);

    public List<GisPoint> findAllByBusinessCategory(String businessCategory);

    @Transactional
    public int deleteGisPointByBusinessCategory(String businessCategory);

    @Modifying
    @Transactional
    @Query("update GisPoint g set g = ?2 where g.objId =?1")
    public int updateGisPoint(Long objId, GisPoint p);


    @Modifying
    @Transactional
    // @Query("update GIS_POINT SET CODE = ?1,NAME = ?2,YW_CATEGORY = ?3 ,LONGITUDE = ?4 ,LATITUDE=?5 ,OBJ_TYPE = ?6 ,OBJ_CODE = ?7 ,BUSINESS_CATEGORY = ?8 WHERE OBJ_ID = ?9 ")
    @Query(value = "update GIS_POINT SET CODE = ?1,NAME = ?2,YW_CATEGORY = ?3 ,LONGITUDE = ?4 ,LATITUDE=?5 ,OBJ_TYPE = ?6 ,OBJ_CODE = ?7 ,BUSINESS_CATEGORY = ?8 WHERE OBJ_ID = ?9",nativeQuery = true)
    public int updateGisPointNew(String code, String name, String ywCategory, double longitude, double latitude, long objType, String objCode, String businessCategory, long objId);

    public GisPoint findGisPointByCodeAndBusinessCategory(String code, Long businessCategory);


}
